home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / 3DGPL.ZIP / 3DGPL / CODE / ENGINE / ENG-BASE.C next >
Encoding:
C/C++ Source or Header  |  1995-06-20  |  2.5 KB  |  55 lines

  1. /** 3DGPL *************************************************\
  2.  *  ()                                                    *
  3.  *  Header for the 3D engine.                             *
  4.  *                                                        *
  5.  *  Defines:                                              *
  6.  *   M_render_polygon        rendering a generic polygon; *
  7.  *                                                        *
  8.  *  (6/1995) By Sergei Savhenko. (savs@cs.mcgill.ca).     *
  9.  *  Copyright (c) 1995 Sergei Savchenko.                  *
  10.  *  THIS SOURCE CODE CAN'T BE USED FOR COMERCIAL PURPOSES *
  11.  *  WITHOUT AUTHORISATION                                 *
  12. \**********************************************************/
  13.  
  14. #include "../hardware/hardware.h"           /* fast memory moves */
  15. #include "../graphics/graphics.h"           /* 2-D rendering */
  16. #include "../trans/trans.h"                 /* 3-D transformations */
  17. #include "../clipper/clipper.h"             /* 2-D/3-D clipping */
  18. #include "../engine/engine.h"               /* 3-D engine */
  19.  
  20. /**********************************************************\
  21.  *  Rendering a generic polygon in perspective.           *
  22. \**********************************************************/
  23.  
  24. void M_render_polygon(struct M_polygon *poly,int *vertex,int *vectors)
  25. {
  26.  int tmp1[M_POLYGON_LENGTH_LIMIT],tmp2[M_POLYGON_LENGTH_LIMIT];
  27.  int *tuples1=tmp1,*tuples2=tmp2,number,cnd;
  28.  
  29.  if((cnd=C_volume_clipping(poly->m_edges,tuples1,vertex,poly->m_id,
  30.                            1+(number=poly->m_no_edges)))!=0)
  31.  {
  32.   if(cnd==-1) number=C_polygon_z_clipping(tuples2=tmp1,tuples1=tmp2,
  33.                                           poly->m_id,number
  34.                                          );
  35.   T_perspective(tuples1,tuples2,poly->m_id,number+1);
  36.   switch(poly->m_id)
  37.   {
  38.    case M_AMBIENT: G_ambient_polygon(tuples2,number,poly->m_colour);
  39.                    break;
  40.    case M_SHADED:  G_shaded_polygon(tuples2,number);
  41.                    break;
  42.    case M_TEXTURED:G_textured_polygon(tuples2,number,tuples1,
  43.                                       &vectors[poly->m_u_index],
  44.                                       &vectors[poly->m_v_index],
  45.                                       poly->m_texture,
  46.                                       poly->m_log_texture_size,
  47.                                       poly->m_log_texture_scale
  48.                                      );
  49.                    break;
  50.   }
  51.  }
  52. }
  53.  
  54. /**********************************************************/
  55.